package com.cskaoyan.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author stone
 * @date 2022/05/30 14:46
 */
@Controller
public class HelloController {

    // 访问hello请求时，能够出现hello ligenli
    @RequestMapping("hello")
    public ModelAndView hello() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/index.jsp");
        modelAndView.addObject("name", "ligenli");
        return modelAndView;
    }

    @RequestMapping("hello2")
    public String hello2(Model model) {
        model.addAttribute("name", "songge");
        return "/index.jsp";
    }
}
